package com.company.netty;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

/**
 * @description: some desc
 * @author: ruoan
 * @date: 2020/12/30 21:27
 */
public class TimeDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        //System.out.println("decode: "+System.currentTimeMillis());
        //if (in.readableBytes() < 4) {
        //    return;
        //}
        //out.add(in.readBytes(4));


        if (in.readableBytes() < 4) {
            return;
        }

        out.add(new UnixTime(in.readUnsignedInt()));
    }


}
